﻿using B.S.BaseData.ErrorCode;
using B.S.BaseData.Write.API.Application.Command;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace B.S.BaseData.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedingController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public BreedingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 养殖信息添加
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<ApiResult<object>> BreedAdd(BreedingCreateCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 养殖删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<ApiResult<object>> BreedingDelete(BreedingDeleteCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 养殖修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<object>> BreedingUpdate(BreedingUpdateCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
